//
// Created by yunnan xu on 2020/11/9.
//

#ifndef ANDROIDGRAPHICSDEMOS_SHADERMGR_H
#define ANDROIDGRAPHICSDEMOS_SHADERMGR_H

#include <vector>
#include <unordered_map>
#include <string>
#include <GLES3/gl32.h>
#include "Singleton.h"


enum ShaderType
{
    VertexShader,
    FragmentShader,
    GeometryShader,
    TessControlShader,
    TessEvaluateShader,
    ComputeShader,
    Count
};


class ShaderMgr
{

public:
    ShaderMgr() = default;
    virtual ~ShaderMgr() = default;

    static char ShaderSuffix[6][12];
    static int GLShaderEnum[6];
};


class GLESShaderMgr : public ShaderMgr, public Singleton<GLESShaderMgr>
{
public:
    GLESShaderMgr();
    virtual ~GLESShaderMgr();

    void LoadShaderList(const std::vector<std::string> & fileNameList);
    GLuint GetShaderByPath(const std::string & path);

private:

    static std::string ShaderDictionaryPath;
    std::unordered_map<std::string, const char *> shaderSources;
    bool CreateAndCompileShader(std::string file_path, const char * shader_source);
    std::unordered_map <std::string, GLuint> shaderDict;
};






#endif //ANDROIDGRAPHICSDEMOS_SHADERMGR_H
